﻿using BYSJ.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Data.Entity;
namespace BYSJ.EFDAL
{
   public class DbContextFactory
    {
        public static ModelContainer dbEntities()
        {
                DbContext dbContext = CallContext.GetData("DbContext") as DbContext;
                if (dbContext == null)
                {
                    dbContext = new BYSJ.Model.ModelContainer();
                    //dbContext.Configuration.ValidateOnSaveEnabled = false;
                    //将新创建的 ef上下文对象 存入线程
                    CallContext.SetData("DbContext", dbContext);
                    //dbContext.Database.Log = LogSave.TrackLogSave;
                }
                return dbContext as ModelContainer;
            
        }
    }
}
